<template>
  <div id="rose-chart">
    <div id="main3" style="height: 85%;"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts';


export default {
  name: 'RoseChart',
  data() {
    return {
      option: {},
    }
  },
  methods: {
    showCharts() {
      var myChart = echarts.init(document.querySelector("#main3"));      //1:获取dom元素
      // 绘制图表
      const option = {                                              //2：配置项
        // title: {
        //   text: 'Stacked Line',
        //   textStyle: {
        //     color: '#fff' // 这里设置标题颜色为红色
        //   }
        // },
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['Email', 'Union Ads'],
          textStyle: { //图例文字的样式
            color: '#fff',
            fontSize: 16
          },
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
          axisLabel: {
            show: true,
            textStyle: {
              color: '#fff'
            }
          }

        },
        yAxis: {
          type: 'value',
          axisLabel: {
            show: true,
            textStyle: {
              color: '#fff'
            }
          }
        },
        series: [
          {
            name: 'Email',
            type: 'line',
            stack: 'Total',
            data: [120, 132, 101, 134, 90, 230, 210],
            itemStyle: {
                normal: {
                  color: function () { return "#" + Math.floor(Math.random() * (256 * 256 * 256 - 1)).toString(16); }
                },
              },
          },
          {
            name: 'Union Ads',
            type: 'line',
            stack: 'Total',
            data: [220, 182, 191, 234, 290, 330, 310],
            itemStyle: {
                normal: {
                  color: function () { return "#" + Math.floor(Math.random() * (256 * 256 * 256 - 1)).toString(16); }
                },
              },
          },
        ]
      };
      myChart.setOption(option);                              //3：挂载配置项
    },

  },
  mounted() {
    this.showCharts();
  },
}

</script>

<style lang="less">
#rose-chart {
  height: 100%;
  box-sizing: border-box;
  background-color: rgba(6, 30, 93, 0.5);
}
</style>
